package com.goodving.guli.utility;

import android.animation.ObjectAnimator;
import android.app.Dialog;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.goodving.guli.R;

/**
 * Created by Administrator on 2015/11/17 0017.
 */
public class C1076y extends FragmentActivity {
    public static final String f3848r;
    private ProgressBar f3849q;
    protected Toast f3850s;
    protected Dialog f3851t;

    public C1076y() {
        this.f3850s = null;
        this.f3851t = null;
    }

    static {
        f3848r = C1076y.class.getSimpleName();
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        m7644l();
    }

    public void tapCancel(View view) {
        finish();
    }

    public void m7646b(String str) {
        m7645a(str, 0);
    }

    public void m7645a(String str, int i) {
        if (this.f3850s == null) {
            this.f3850s = Toast.makeText(this, str, i);
        } else {
            this.f3850s.setText(str);
            this.f3850s.setDuration(i);
        }
        this.f3850s.show();
    }

    private Dialog m7643k() {
        Dialog dialog = new Dialog(this, R.style.ProgressDialog);
        View inflate = LayoutInflater.from(this).inflate(R.layout.loading_dialog, null);
        ImageView imageView = (ImageView) inflate.findViewById(R.id.image_man);
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat((ImageView) inflate.findViewById(R.id.image_circle), "rotation", new float[]{0.0f, 359.0f});
        ofFloat.setInterpolator(new LinearInterpolator());
        ofFloat.setDuration(1000);
        ofFloat.setRepeatCount(-1);
        ofFloat.start();
        ofFloat = ObjectAnimator.ofFloat(imageView, "alpha", new float[]{C1965e.f9059c, 0.5f});
        ofFloat.setDuration(1500);
        ofFloat.setInterpolator(new LinearInterpolator());
        ofFloat.setRepeatCount(-1);
        ofFloat.start();
        dialog.setContentView(inflate);
        dialog.setCancelable(false);
        return dialog;
    }

    public synchronized void m7647c(String str) {
        if (this.f3851t == null) {
            this.f3851t = m7643k();
            this.f3851t.show();
        } else {
            this.f3851t.show();
        }
    }

    public synchronized void m7648o() {
        if (this.f3851t != null) {
            this.f3851t.dismiss();
        }
    }

    private void m7644l() {
        if (Build.VERSION.SDK_INT == 18) {
            View findViewById = findViewById(android.R.id.content);
            if (findViewById instanceof FrameLayout) {
                TypedValue typedValue = new TypedValue();
                if (getTheme().resolveAttribute(16842841, typedValue, true) && typedValue.resourceId != 0) {
                    ((FrameLayout) findViewById).setForeground(getResources().getDrawable(typedValue.resourceId));
                }
            }
        }
    }
}
